/*package com.znf4.controller.bank;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.znf4.controller.common.BaseController;
import com.znf4.controller.common.ConstantClass;
import com.znf4.controller.common.JSONParam;

*//**
 * 银行卡信息
 *//*
@Controller
@RequestMapping("/merchant/bank")
public class BankCardController extends BaseController {
	
	private static final Log log = LogFactory.getLog(BankCardController.class);
	
	@Autowired
	private RemitBankInfoService remitBankInfoService;	//银行信息
	
	@Autowired
	private RpUserBankCardService rpUserBankCardService;	//商户银行账户
	
	@Autowired
	private RemitBankTypeService remitBankTypeService;	//结算银行账户
	
	@Autowired
	private RpUserInfoService rpUserInfoService;	//商户信息
	
	@Autowired
	private SmsCodeService smsCodeService;//短信
	
	
	*//**
	 * 函数功能说明 ： 查询银行账户记录
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequestMapping(value = "/getBankCardList", method = { RequestMethod.POST, RequestMethod.GET })
	public String getBankCardList(HttpServletRequest request) {
		return "bank/list";
	}

	@RequestMapping(value = "/ajaxBankCardList", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public String ajaxBankCardList(HttpServletRequest request, @RequestBody JSONParam[] params) throws IllegalAccessException, InvocationTargetException {
		// convertToMap定义于父类，将参数数组中的所有元素加入一个HashMap
		HashMap<String, String> paramMap = convertToMap(params);
		String sEcho = paramMap.get("sEcho");
		int start = Integer.parseInt(paramMap.get("iDisplayStart"));
		int length = Integer.parseInt(paramMap.get("iDisplayLength"));
		String bankAccountNo = paramMap.get("bankAccountNo");
		RpUserInfo rpUserInfo = (RpUserInfo) request.getSession().getAttribute(ConstantClass.USER);
		String userNo = rpUserInfo.getUserNo();//获取商户编号
		
		// 页面当前页需要显示的记录数据
		PageParam pageParam = new PageParam(start / length + 1, length);
		Map<String, Object> bankCardMap = new HashMap<String, Object>();
		bankCardMap.put("bankAccountNo", bankAccountNo);
		bankCardMap.put("userNo", userNo);
		bankCardMap.put("status", "ACTIVE");//激活
		PageBean pageBean = rpUserBankCardService.listPage(pageParam, bankCardMap);
		Long count = Long.valueOf(pageBean.getTotalCount() + "");
		String jsonString = JSON.toJSONString(pageBean.getRecordList());
		String json = "{\"sEcho\":" + sEcho + ",\"iTotalRecords\":" + count.longValue() + ",\"iTotalDisplayRecords\":" + count.longValue() + ",\"aaData\":" + jsonString + "}";
		return json;
	}
	
	*//**
	 * 函数功能说明 ： 查询银行信息
	 * 
	 * @参数： @return @return String @throws
	 *//*

	@RequestMapping(value = "/ajaxBankInfoList", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public String ajaxBankInfoList(HttpServletRequest request, @RequestBody JSONParam[] params) throws IllegalAccessException, InvocationTargetException {
		// convertToMap定义于父类，将参数数组中的所有元素加入一个HashMap
		HashMap<String, String> paramMap = convertToMap(params);
		String sEcho = paramMap.get("sEcho");
		int start = Integer.parseInt(paramMap.get("iDisplayStart"));
		int length = Integer.parseInt(paramMap.get("iDisplayLength"));
		String bankName = paramMap.get("bankName");
		String province = paramMap.get("province");
		
		// 页面当前页需要显示的记录数据
		PageParam pageParam = new PageParam(start / length + 1, length);
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("bankName", bankName);
		param.put("province", province);
		PageBean pageBean = remitBankInfoService.listPage(pageParam, param);
		Long count = Long.valueOf(pageBean.getTotalCount() + "");
		String jsonString = JSON.toJSONString(pageBean.getRecordList());
		String json = "{\"sEcho\":" + sEcho + ",\"iTotalRecords\":" + count.longValue() + ",\"iTotalDisplayRecords\":" + count.longValue() + ",\"aaData\":" + jsonString + "}";
		System.out.println(json);
		return json;
	}
	
	
	
	*//**
	 * 函数功能说明 ： 添加
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	@ResponseBody
	public ApiCommonResultVo add(HttpServletRequest request) {
		String bankChannelNo = request.getParameter("bankChannelNo"); // 获取银行行号
		String bankAccountNo = request.getParameter("bankAccountNo");
		String bankAccountType = request.getParameter("bankAccountType");
		String bankAccountName = request.getParameter("bankAccountName");
		String cardType = request.getParameter("cardType");
		String cardNo = request.getParameter("cardNo");
		String street = request.getParameter("street");
		String mobileNo = request.getParameter("mobileNo");
		String mobile = request.getParameter("mobile");
		String code = request.getParameter("code");		//验证码
		//验证信息
		if(StringUtil.isEmpty(bankChannelNo)) {
			return new ApiCommonResultVo(-1,"操作失败，银行编号为空","");
		}
		if(StringUtil.isEmpty(bankAccountNo)) {
			return new ApiCommonResultVo(-1,"操作失败，银行账户为空","");
		}
		if(StringUtil.isEmpty(bankAccountName)) {
			return new ApiCommonResultVo(-1,"操作失败，银行开户名为空","");
		}
		if(StringUtil.isEmpty(cardType)) {
			return new ApiCommonResultVo(-1,"操作失败，证件类型为空","");
		}
		if(StringUtil.isEmpty(cardNo)) {
			return new ApiCommonResultVo(-1,"操作失败，证件号码为空","");
		}
		if(StringUtil.isEmpty(street)) {
			return new ApiCommonResultVo(-1,"操作失败，开户银行详细地址","");
		}
		if(StringUtil.isEmpty(mobileNo)) {
			return new ApiCommonResultVo(-1,"操作失败，开户手机号为空","");
		}
		if(StringUtil.isEmpty(mobile)) {
			return new ApiCommonResultVo(-1,"操作失败，平台手机号为空","");
		}
		if(StringUtil.isEmpty(code)){
			return new ApiCommonResultVo(-1,"操作失败，验证码为空","");
		}
		
		//核实验证码
		SmsCodePo codePo = smsCodeService.selectOne(mobile);
		if(codePo == null || !codePo.getCode().equals(code)){
			return new ApiCommonResultVo(-1,"操作失败，验证码错误","");
		}
		
		
		//验证银行卡是否已存在
		RpUserInfo rpUserInfo = (RpUserInfo) request.getSession().getAttribute(ConstantClass.USER);
		List<RpUserBankCard> rpUserBankCards = rpUserBankCardService.getAllByUserNo(rpUserInfo.getUserNo(), PublicStatusEnum.ACTIVE.name(), null);
		if(StringUtil.isNotNull(rpUserBankCards)) {
			for (RpUserBankCard rpUserBankCard : rpUserBankCards) {
				if(rpUserBankCard.getBankAccountNo().equals(bankAccountNo)) {
					return new ApiCommonResultVo(-1,"该银行卡已存在","");
				}
			}
		}
		
		// 根据银行行号查询银行信息
		RemitBankInfo remitBankInfo = remitBankInfoService.getByBankChannelNo(bankChannelNo);
		String typeCode = bankChannelNo.substring(0, 3);
		RemitBankType remitBankType = remitBankTypeService.getByTypeCode(typeCode);
		String bankCode = remitBankType.getBankCode();
		// 验证银行卡是否支持
		if (StringUtil.isEmpty(bankCode)) {
			return new ApiCommonResultVo(-1,"该银行卡不支持","");
			}
		try {
			RpUserBankCard bankAccount = new RpUserBankCard();
			bankAccount.setUserNo(rpUserInfo.getUserNo());
			bankAccount.setBankChannelName(remitBankInfo.getBankName()); // 银行名称
			bankAccount.setBankChannelNo(bankChannelNo); // 银行行号
			bankAccount.setProvince(remitBankInfo.getProvince()); // 省份
			bankAccount.setCity(remitBankInfo.getCity()); // 城市
			bankAccount.setBankCode(remitBankType.getBankCode()); // 银行编码
			bankAccount.setBankName(remitBankType.getTypeName()); // 银行行别名称
			bankAccount.setClearBankChannelNo(remitBankInfo.getClearBankChannelNo()); // 清算银行行号
			bankAccount.setBankAccountType(bankAccountType); // 银行账户类型
			bankAccount.setBankAccountName(bankAccountName); // 开户名
			bankAccount.setBankAccountNo(bankAccountNo); // 银行账户编号
			bankAccount.setStreet(street);                  // 银行具体地址
			bankAccount.setCardType(cardType);
			bankAccount.setCardNo(cardNo);
			bankAccount.setMobileNo(mobileNo);
			// 创建用户结算银行卡
			rpUserBankCardService.createUserBankCard(bankAccount);
		} catch (Exception e) {
			return new ApiCommonResultVo(-1,"创建银行卡操作失败","");
		}
		return new ApiCommonResultVo(0,"操作成功","");
	}
	
	*//**
	 * 函数功能说明 ： 修改展示
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequestMapping(value = "/editUI", method = RequestMethod.POST)
	@ResponseBody
	public ApiCommonResultVo editUI(HttpServletRequest request) {
		String id = request.getParameter("id");
		RpUserBankCard rpUserBankCard = null;
		try {
			//获取该用户数据
			rpUserBankCard = rpUserBankCardService.getById(id);//通过主键获取账户信息
		}catch (Exception e) {
			return new ApiCommonResultVo(-1,"操作异常,获取数据失败","");
		}
		return new ApiCommonResultVo(0,"操作成功，获取数据成功",rpUserBankCard);
	}
	
	*//**
	 * 函数功能说明 ：修改
	 * 
	 * @参数： @return @return String @throws
	 *//*
	*//**
	 * @param request
	 * @return
	 *//*
	@RequestMapping(value = "/edit", method = RequestMethod.POST)
	@ResponseBody
	public ApiCommonResultVo edit(HttpServletRequest request) {
		String id = request.getParameter("id");
		String bankName = request.getParameter("bankName");
		String bankChannelNo = request.getParameter("bankChannelNo"); // 获取银行行号
		String bankAccountNo = request.getParameter("bankAccountNo");
		String bankAccountType = request.getParameter("bankAccountType");
		String bankAccountName = request.getParameter("bankAccountName");
		String cardType = request.getParameter("cardType");
		String cardNo = request.getParameter("cardNo");
		String street = request.getParameter("street");
		String mobileNo = request.getParameter("mobileNo");
		String mobile = request.getParameter("mobile");
		String code = request.getParameter("code");		//验证码
		//验证信息
		if(StringUtil.isEmpty(bankName)) {
			return new ApiCommonResultVo(-1,"操作失败，银行名称为空","");
		}
		if(StringUtil.isEmpty(bankChannelNo)) {
			return new ApiCommonResultVo(-1,"操作失败，银行编号为空","");
		}
		if(StringUtil.isEmpty(bankAccountNo)) {
			return new ApiCommonResultVo(-1,"操作失败，银行账户为空","");
		}
		if(StringUtil.isEmpty(bankAccountName)) {
			return new ApiCommonResultVo(-1,"操作失败，银行开户名为空","");
		}
		if(StringUtil.isEmpty(cardType)) {
			return new ApiCommonResultVo(-1,"操作失败，证件类型为空","");
		}
		if(StringUtil.isEmpty(cardNo)) {
			return new ApiCommonResultVo(-1,"操作失败，证件号码为空","");
		}
		if(StringUtil.isEmpty(street)) {
			return new ApiCommonResultVo(-1,"操作失败，开户银行详细地址","");
		}
		if(StringUtil.isEmpty(mobileNo)) {
			return new ApiCommonResultVo(-1,"操作失败，开户手机号为空","");
		}
		if(StringUtil.isEmpty(mobile)) {
			return new ApiCommonResultVo(-1,"操作失败，平台手机号为空","");
		}
		if(StringUtil.isEmpty(code)){
			return new ApiCommonResultVo(-1,"操作失败，验证码为空","");
		}
		
		//核实验证码
		SmsCodePo codePo = smsCodeService.selectOne(mobile);
		if(codePo == null || !codePo.getCode().equals(code)){
			return new ApiCommonResultVo(-1,"操作失败，验证码错误","");
		}
		
		
		//验证银行卡是否已存在
		RpUserInfo rpUserInfo = (RpUserInfo) request.getSession().getAttribute(ConstantClass.USER);
		List<RpUserBankCard> rpUserBankCards = rpUserBankCardService.getAllByUserNo(rpUserInfo.getUserNo(), PublicStatusEnum.ACTIVE.name(), null);
		if(StringUtil.isNotNull(rpUserBankCards)) {
			for (RpUserBankCard rpUserBankCard : rpUserBankCards) {
				if(rpUserBankCard.getBankAccountNo().equals(bankAccountNo) && rpUserBankCard.getStatus().equals(PublicStatusEnum.ACTIVE.name()) 
						&& !rpUserBankCard.getIsAudit().equals(BankCardAuditEnum.CANCEL_FAIL.name())) {
					return new ApiCommonResultVo(-1,"该银行卡已存在","");
				}
			}
		}
		
		// 根据银行行号查询银行信息
		RemitBankInfo remitBankInfo = remitBankInfoService.getByBankChannelNo(bankChannelNo);
		String typeCode = bankChannelNo.substring(0, 3);
		RemitBankType remitBankType = remitBankTypeService.getByTypeCode(typeCode);
		String bankCode = remitBankType.getBankCode();
		// 验证银行卡是否支持
		if (StringUtil.isEmpty(bankCode)) {
			return new ApiCommonResultVo(-1,"该银行卡不支持","");
			}
		
		try {
			RpUserBankCard bankAccount = new RpUserBankCard();
			bankAccount.setId(id);
			bankAccount.setUserNo(rpUserInfo.getUserNo());
			bankAccount.setMobileNo(mobileNo);
			bankAccount.setBankChannelName(remitBankInfo.getBankName()); 	// 银行名称
			bankAccount.setBankChannelNo(bankChannelNo); 					// 银行行号
			bankAccount.setProvince(remitBankInfo.getProvince()); 			// 省份
			bankAccount.setCity(remitBankInfo.getCity()); 					// 城市
			bankAccount.setBankCode(remitBankType.getBankCode()); 			// 银行编码
			bankAccount.setBankName(remitBankType.getTypeName()); 			// 银行行别名称
			bankAccount.setClearBankChannelNo(remitBankInfo.getClearBankChannelNo()); // 清算银行行号
			bankAccount.setBankAccountType(bankAccountType);				// 银行账户类型
			bankAccount.setBankAccountName(bankAccountName); 				// 开户名
			bankAccount.setBankAccountNo(bankAccountNo); 					// 银行账户编号
			bankAccount.setStreet(street);                                  // 银行具体地址
			bankAccount.setCardType(cardType);
			bankAccount.setCardNo(cardNo);
			bankAccount.setMobileNo(mobileNo);
			// 创建用户结算银行卡
			rpUserBankCardService.updateUserBankCard(bankAccount);
		} catch (Exception e) {
			return new ApiCommonResultVo(-1,"修改银行卡操作失败","");
		}
		return new ApiCommonResultVo(0,"操作成功","");
	}
	
	
	*//**
	 * 函数功能说明 ： 删除
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequestMapping(value = "/delete", method = RequestMethod.POST)
	@ResponseBody
	public ApiCommonResultVo delete(HttpServletRequest request) {
		String id = request.getParameter("id");
		String status = PublicStatusEnum.UNACTIVE.name();//删除状态
		RpUserBankCard rpUserBankCard = rpUserBankCardService.getById(id);
		try {
			rpUserBankCard.setStatus(status);//删除操作
			rpUserBankCardService.updateUserBankCard(rpUserBankCard);
		} catch (Exception e) {
			return new ApiCommonResultVo(-1,"删除操作失败","");
		}
		return new ApiCommonResultVo(0,"操作成功，删除成功","");
	}
	
	
	
	*//**
	 * 函数功能说明 ： 设为默认
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequestMapping(value = "/isDefault", method = RequestMethod.POST)
	@ResponseBody
	public ApiCommonResultVo isDefault(HttpServletRequest request,@RequestParam(value = "id")String id) {
		RpUserInfo rpUserInfo = (RpUserInfo) request.getSession().getAttribute(ConstantClass.USER);
		try {
			rpUserBankCardService.setDefault(id,rpUserInfo);
		} catch (Exception e) {
			return new ApiCommonResultVo(-1,"操作失败","");
		}
		return new ApiCommonResultVo(0,"操作成功，该卡已设置为默认银行卡","");
	}
	
	*//**
	 * 函数功能说明 ：发送短信验证码
	 * 
	 * @参数： @return
	 * @return String
	 * @throws
	 *//*
	@RequestMapping(value = "/sendSms", method ={RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public ApiCommonResultVo sendSms(HttpServletRequest request, Model model,@RequestParam(value = "mobile") String mobile) throws Exception  {
		RpUserInfo rpUserInfo = rpUserInfoService.getDataByMobile(mobile);
		if (rpUserInfo == null) {
			return new ApiCommonResultVo(-1,"发送失败,用户不存在","");
		}
		String code = RandomUtils.randomInt(4);
		SmsCodePo po = null;
		try {
			po = smsCodeService.insertForAliyun(mobile, code);
		} catch (Exception e) {
			log.info("发送短信异常",e);
			return new ApiCommonResultVo(-1,"发送失败,请稍后再试","");
		}
		if(po.getSuccess().equals("true")){
			return new ApiCommonResultVo(0,"发送成功","");
		}else{
			return new ApiCommonResultVo(-1,"发送失败,请稍后再试","");
		}
	}
	
}
*/